This invention relates to a method and computer system for combining pattern matching and optimization, for example, providing an efficient match between the elements of two data files.